package com.example.administrator.mobilesafe.utils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created by Administrator on 2015/8/25.
 */
public class StreamTools {
    public static String readFromStream(InputStream inputStream) throws IOException{
        ByteArrayOutputStream byteArrayOutputStream =new ByteArrayOutputStream();
        byte[] bytes = new byte[1024];
        int length = 0;
        while ((length = inputStream.read(bytes))!=-1){
            byteArrayOutputStream.write(bytes,0,length);
        }
        String result = byteArrayOutputStream.toString();
        byteArrayOutputStream.close();
        return result;
    }
}
